﻿using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using ColorWheel.Classes;

namespace ColorWheel
{
	public partial class ColorSlice
	{
	    private Color ActiveColor;

	    public delegate void ColorClickHandler(object sender, SliceEventArgs e);
	    public event ColorClickHandler ColorClick;

		public ColorSlice()
		{
			InitializeComponent();
		}

        public void SetColor(Color SliceColor)
        {
            ActiveColor = SliceColor;

            SliceColor1.Color = SliceColor;
            SliceColor2.Color = SliceColor;
        }

        public Color GetColor()
        {
            return ActiveColor;
        }

        private void LayoutRoot_MouseEnter(object sender, MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "Hover", true);
        }

        private void LayoutRoot_MouseLeave(object sender, MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "Normal", true);
        }

        private void Slice_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SliceEventArgs args = new SliceEventArgs(ActiveColor);

            if(ColorClick!=null)
            {
                ColorClick(this, args);
            }
        }
	}
}